﻿using AuthCenter_HuangJingtao.Domain;
using AuthCenter_HuangJingtao.ErrorCode;
using AuthCenter_HuangJingtao.Infrastructure.Imterfaces;
using AuthCenter_HuangJingtao.Read.Api.Application.Command.AppaLL;
using MediatR;
using Microsoft.EntityFrameworkCore;

namespace AuthCenter_HuangJingtao.Read.Api.Application.CommandHandler.AppHandler
{
    public class ShowAddressCommandHandler : IRequestHandler<ShowAddressCommand, ApiResult<List<Addresses>>>
    {
        IBaseReponsitory<Addresses> Addresses;

        public ShowAddressCommandHandler(IBaseReponsitory<Addresses> Addresses)
        {
            this.Addresses = Addresses;
        }

        public async Task<ApiResult<List<Addresses>>> Handle(ShowAddressCommand request, CancellationToken cancellationToken)
        {
         var list=await Addresses.GetQuery().ToListAsync();
            return new ApiResult<List<Addresses>> 
            {
                Code = ApiEnum.Success,
                Message = "获取成功",
                Data = list
            };
        }
    }
}
